<?php require('data/dbcon.php'); ?>
<?php require('data/functions.php'); ?>
<?php
if( empty($_GET['error']) ) {
	if( mysql_query('CREATE TABLE v2_admin (id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,' 
	. ' login TEXT NOT NULL,' 
	. ' password TEXT NOT NULL,' 
	. ' website_name TEXT NOT NULL,'
	. ' website_add TEXT NOT NULL,'
	. ' stat TEXT NOT NULL,' 
	. ' level TEXT NOT NULL)') ) {
	}else{
		print mysql_error();
		print "1";
		exit;
	}
	if( mysql_query('CREATE TABLE v2_posts (id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,' 
	. ' name TEXT NOT NULL,' 
	. ' email TEXT NOT NULL,' 
	. ' post TEXT NOT NULL,' 
	. ' dateadded datetime NOT NULL default "0000-00-00 00:00:00",' 
	. ' stat TEXT NOT NULL)') ) {
	}else{
		print mysql_error();
		print "2";
		exit;
	}
	
	if( mysql_query('CREATE TABLE v2_approved (id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,' 
	. ' email TEXT NOT NULL,' 
	. ' created_at datetime NOT NULL default "0000-00-00 00:00:00")') ) {
	}else{
		print mysql_error();
		print "Approved Table";
		exit;
	}
	
	if( mysql_query('CREATE TABLE v2_spamblock (id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,' 
	. ' dateblocked datetime NOT NULL default "0000-00-00 00:00:00")') ) {
		$install = "<p>One step left! Add your admin account and your all done!</p>";
		$in = TRUE;
	}else{
		print mysql_error();
		
		print "3";
		$install = "<p>SORRY, we could not talk to your database. Go back and try again.</p>";
		$in = FALSE;
	}
}else{
	
		$install = "<p>One step left! Add your admin account and your all done!</p>";
		$in = TRUE;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">@import url('css/body.css'); </style>
<title>Welcome to Winn GuestBook <?=$version; ?></title>
</head>

<body>
<div id="login">
	
    <h2>Install <?=$version; ?> - step 3</h2>
    <?=$install; ?>
    
    <?php if( $in == TRUE ) { ?>
    	<table>
        <form action="install_done.php" method="post">
        	<tr>
            	<td>Login:</td>
                <td><input type="text" name="login" /></td>
            </tr>
            <tr>
            	<td>Password:</td>
                <td><input type="password" name="pass" /></td>
            </tr>
            <tr>
            	<td>Retype:</td>
                <td><input type="password" name="pass2" /></td>
            </tr>
            <tr>
            	<td></td>
                <td><input type="submit" name="save" value="Create &raquo;" /></td>
            </tr>
        </form>
        </table>
    <?php }else{ ?>
    	<p><a href="install.php">&laquo; Go back</a></p>
    <?php } ?>
    
    
</div>
</body>
</html>
